package zwo.service.impl;

import zwo.dao.CategoryMapper;
import zwo.model.Category;
import zwo.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    public Integer cateGoryDelete(Category category) {
        if (categoryMapper.cateDeleteNotnull(category) == 0) {
            return categoryMapper.cateGoryDelete(category);
        } else if (categoryMapper.cateDeleteNotnull(category) > 1) {
            return 2;
        } else {
            return 3;
        }
    }

    /**
     * 后台 添加分类 判断分类名称是否存在
     *
     * @param category
     * @return
     */
    public Integer cateGoryAdd(Category category) {
        if (categoryMapper.cateNameiSnull(category) == 0) {
            return categoryMapper.cateGoryAdd(category);
        } else {
            return 0;
        }
    }


}
